#pragma once
#include <GL/glew.h>
#include <Display/Renders/render.h>
#include <Display/Renders/shader_program.h>

namespace PhysLeo {

/**
 * point render cpu version
 */
template<typename T>
class PointRenderCpu :public Render<T> {
public:
	PointRenderCpu();

    PointRenderCpu(const PointRenderCpu<T>&) = delete;

    PointRenderCpu(PointRenderCpu<T>&&) = delete;

    PointRenderCpu<T>& operator=(const PointRenderCpu<T>&) = delete;

    PointRenderCpu<T>& operator=(PointRenderCpu<T>&&) = delete;

	~PointRenderCpu();

    void init(SimData<T> &simData) override;
    void draw(CameraInterface &camera) override;
    void transformToDrawData() override;
    void updateDrawData() override;

	//write file support
	void setWritable(const int saveFrames) { save_frames_ = saveFrames; writable_ = true; cnt_ = 0; }
	void setExportFilePath(const std::string filepath) { filename_ = filepath; }

protected:
    void exportPointXyz();

	std::shared_ptr<BufferData<glm::tvec3<T>>> ptr_pos_;
	std::shared_ptr<BufferData<glm::vec3>> ptr_pos_copy_;

	int num_points_;
	GLuint vao_;
	GLuint vbo_;
	ShaderProgram shader_;

	//write file support
	bool writable_;
	std::string filename_;
	int cnt_;
	int save_frames_;
};

}